Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: invalidate persisted cache #635

Merged
merged 19 commits into from
Aug 27, 2024
Merged

Conversation

ShawkyZ
Copy link
Contributor

@ShawkyZ ShawkyZ commented Aug 22, 2024

Description

  • Check every 12 hours for expired persisted cache (using file last modified date) and delete them.
  • Move init logic for persiseter to be triggered if workspace folders changed.

Checklist

  • Tests added and all succeed
  • Linted
  • README.md updated, if user-facing
  • License file updated, if new 3rd-party dependency is introduced

workspace.Get().ChangeWorkspaceFolders(bgCtx, params)
command.HandleFolders(bgCtx, srv, di.Notifier())
changedFolders := workspace.Get().ChangeWorkspaceFolders(params)
command.HandleFolders(bgCtx, srv, di.Notifier(), di.ScanPersister())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i moved the persister init logic to the folder handlers
This refactoring here was to make sure that the persister is initialized before a new f.ScanFolder is triggered for the new added folder

@ShawkyZ ShawkyZ changed the title Feat/invalidate persisted cache fat: invalidate persisted cache Aug 26, 2024
@ShawkyZ ShawkyZ changed the title fat: invalidate persisted cache feat: invalidate persisted cache Aug 26, 2024
@ShawkyZ ShawkyZ requested a review from a team as a code owner August 26, 2024 10:00
for _, folder := range params.Event.Removed {
w.RemoveFolder(uri.PathFromUri(folder.Uri))
}

var changedWorkspaceFolders []*Folder
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to avoid triggering scan before initializing the persister.
Caller is responsible for calling the scan for the new added folders

@@ -38,6 +39,10 @@ const (
SchemaVersion = "v1"
)

var (
ExpirationInSeconds = 12 * 60 * 60
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a constant to be able to override it in tests

@@ -73,7 +73,7 @@ func Test_TrustFoldersAndScan_shouldAddFoldersToTrustedFoldersAndTriggerScan(t *
}, time.Second, time.Millisecond, "scanner should be called after trust is granted")
}

func Test_AddAndRemoveFoldersAndTriggerScan(t *testing.T) {
func Test_AddAndRemoveFoldersAndReturnFolderList(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you test the extracted trigger scan path now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in server_test Test_workspaceDidChangeWorkspaceFolders_shouldProcessChanges it checks if folder.Scanned()
I think it should be enough, wdyt ?

@ShawkyZ ShawkyZ merged commit d7076e4 into main Aug 27, 2024
19 checks passed
@ShawkyZ ShawkyZ deleted the feat/invalidate-persisted-cache branch August 27, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants